﻿using CsvHelper;
using DataAchive.Model.Excel.Export;
using NPOI.OpenXmlFormats.Vml;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAchive.Helper
{

    internal class ReportExport<T> 
    {
       
        public static void ExportCsv(List<T>details,string filename) 
        {
            //string csvPath = string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, filename);
            string csvPath = filename;
            using (var writer = new StreamWriter(csvPath, append: false, Encoding.UTF8))
            {
                using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                {

                    csv.WriteRecords(details);

                }
            }
        }

        public static void ExportXsls(List<T> details,string filename)
        {
            List<string> cols = new List<string>()
            {
                "设备号",               
                "站点号",
                "条码",
                "记录时间",
                "完成时间",
                "AI检出缺陷",
                "人工检出缺陷",
                "AI判断结果",
                "人工判断结果",
                "检测类型",
                "人工复判时间",
                "分类"              
            };
            ExcelHelper.ExportColumn(filename, details, null, "详情");
        }
    }
}
